<template>
	<view class="" style="min-height: 100vh;background-color: #F7F8FA;padding-bottom: 120rpx;">
		<view class="comteMenst"></view>
		<view class="menTnegsMe">
			<view class="consmeCome" >
				<view @click="goPages('/pages/ai/essentialInformation')" style="display: flex;align-items: center;justify-content: space-between;border-bottom: 1rpx solid #E1E4E8;padding-bottom: 15rpx;">
					<view class="">
						<view class="tilrwmeEme" style="display: flex;align-items: flex-start">
							<text class="xiusb" v-if="formData.full_name">{{formData.full_name}}</text>
						</view>
						<view class="mensetiem" v-if="formData.education">
							 {{formData.education}}  {{formData.operational_field}} 
						</view>
					</view>
					<image class="imAvatar"   :src="formData.avatar?'https://app.zizijy.com/'+formData.avatar:avatar"  mode=""></image>
				</view>
				<view class="" style="padding-top: 20rpx;">
					<view class="uneSunbtirle">
						<text>个人介绍</text>
						<image class="imgebs" :src="imgUrl+'/edit.png'" @click="goPages('/resume/personal/index')" mode=""></image>
					</view>
					<view class="mensetiem" v-if="formData.introduce">
						{{formData.introduce}}
					</view>
				</view>
			</view>
			<view class="consmeCome">
				<view class="tilrwme">
					<text>求职意向</text>
					<view class="comRime" style="display: flex;align-items: center;">
						<view class="com" @click="goPages('/resume/JobIntention/index')">修改</view>
					</view>
				</view>
				<view class="mensetiem" v-if="formData.yx_chengshi">
					意向城市:{{formData.yx_chengshi}}
				</view>
				<view class="mensetiem" v-if="formData.yx_gangwei">
					意向岗位:{{formData.yx_gangwei}}
				</view>
				
		    </view>
			
			<view class="consmeCome">
				<view class="tilrwme">
					<text>教育经历</text>
				</view>
				<view class="" v-for="(item,index) in formData.workexp1" >
					<view class="uneSunbtirle">
						<text>{{item.title}}</text>
						<view class="comRime" style="display: flex;align-items: center;">
							<view class="com" @click="jinRemse(item.id)">删除</view>
							<view class="com" @click="goPages('/resume/education/index?type=1&webConmen='+item.id)">修改</view>
						</view>
					</view>
					<view class="mensetiem">
						{{item.starttime}}-{{item.endtime}}·{{item.education}}·{{item.com_name}}
					</view>
					<view class="mensetiem">
						{{item.content}}
					</view>
				</view>
			</view>
			<view class="tianiazengs" @click="goPages('/resume/education/index?type=1')">
				+ 添加教育经历
			</view>
			<view class="consmeCome">
				<view class="tilrwme">
					<text>工作经历</text>
				</view>
				<view class="" v-for="(item,index) in formData.workexp2" >
					<view class="uneSunbtirle">
						<text>{{item.title}}</text>
						<view class="comRime" style="display: flex;align-items: center;">
							<view class="com" @click="jinRemse(item.id)">删除</view>
							<view class="com" @click="goPages('/resume/education/index?type=2&webConmen='+item.id)">修改</view>
						</view>
					</view>
					<view class="mensetiem">
						{{item.starttime}}-{{item.endtime}}·{{item.com_name}}
					</view>
					<view class="mensetiem">
						{{item.content}}
					</view>
				</view>
			</view>
			
			<view class="tianiazengs" @click="goPages('/resume/education/index?type=2')">
				+ 添加工作经历
			</view>
			<view class="consmeCome">
				<view class="uneSunbtirle">
					<text>获得证书</text>
					<image class="imgebs" :src="imgUrl+'/edit.png'" @click="goPages('/resume/certificate/certificateList')" mode=""></image>
					<!-- certificateList -->
				</view>
				<view class="tbs">
					<view class="tbsmens" v-for="(item,index) in formData.workcert">
						<image class="tenImg" src="../../static/wenja.png" mode=""></image> {{item.title}}
					</view>
				</view>
			</view>
			<view class="consmeCome">
				<view class="tilrwme">
					<text>技能标签</text>
					<image class="imgebs" :src="imgUrl+'/edit.png'" @click="goPages('/resume/label/index?label='+formData.label.join(','))" mode=""></image>
				</view>
				<view class="tbs">
					<view class="tbs-list" v-for="(item,index) in formData.label">{{item}}</view>
				</view>
			</view>
			
			
				<view class="btn" @click="getJianli">下载简历</view>
				
			
		</view>
	</view>
</template>

<script>
	import {
		Request
	} from '@/utils/request.js'
	export default{
		data(){
			return {
				imgUrl:this.imgUrl,
				formData:{},
				avatar:require('../../static/21723798284_.pic_hd.png'),
			}
		},
		onLoad() {			
			// this.userInfo();
		},
		onShow() {
			this.userInfo();
		},
		methods:{
			goPages(path,_fakse){
				uni.navigateTo({
					url:path
				})
			},
			getJianli(){
				Request('createPdf',{
					user_id:this.formData.uid,
				}).then((res)=>{
					this.downLoad(res.url);
					// uni.setClipboardData({
					// 	data: res.url,
					// 	success: function () {
					// 		uni.showToast({
					// 			title: '复制成功，请到浏览器打开',
					// 			icon: 'none'
					// 		  });
					// 		console.log('success');
					// 	}
					// });   	
					
				})
				
			},
			// 下载
			downLoad(fileUrl) {
			    console.log('下载');
			    // 获取系统信息
			    const systemInfo = uni.getSystemInfoSync();
			    const isH5 = systemInfo.platform === 'h5';  // 判断是否是H5平台
			    console.log(systemInfo);
			    console.log(isH5);
			    if (isH5) {
			        console.log('当前环境是H5');
			        // 如果是H5，可以在这里进行一些H5特有的处理
			        // 比如提示用户下载会受到浏览器限制，或者直接跳转到下载链接等
			        window.open(fileUrl, '_blank');  // '_blank'表示在新标签页中打开
			    } else {
			        console.log('当前环境是非H5平台');
			        uni.downloadFile({
			            url: fileUrl,
			            method: 'GET',
			            success: (data) => {
			                console.log(data);
			                if (data.statusCode === 200) {
			                    console.log(data);
			                    //文件保存到本地
			                    uni.saveFile({
			                        tempFilePath: data.tempFilePath, //临时路径
			                        success: function (res) {
			                            console.log(res);
			                            uni.showToast({
			                                icon: 'none',
			                                mask: true,
			                                title: '文件已保存：' + res.savedFilePath, //保存路径
			                                duration: 3000,
			                            });
			                            setTimeout(() => {
			                                //打开文档查看
			                                uni.openDocument({
			                                    filePath: res.savedFilePath,
			                                    success: function (res) {
			                                        console.log('打开文档成功');
			                                    }
			                                });
			                            }, 3000)
			                        }
			                    });
			                }
			            },
			            fail: (err) => {
			                console.log(err);
			                if (err.errMsg == "downloadFile:fail") {
			                    setTimeout(() => {
			                        // window.open(courseDetail.file, '_blank');
			                    }, 2000);
			                }
			                uni.showToast({
			                    title: '下载失败请重新下载',
			                    icon: 'none',
			                    mask: true
			                });
			            },
			        });
			    }
			},
			deleteFuns(indx,type){
				 if(type==1){
					 this.formData.workexp1.splice(indx,1)
					 this.formData =this.formData;
				 }else{
					 this.formData.workexp2.splice(indx,1)
					 this.formData =this.formData;
				 }
				 // formData.workexp1
				 uni.showToast({
				 	title:'成功',
				 	icon:'none'
				 })
			},
			delworkExp(itemID,index,type){
				Request('user/curriculum_vitae/delworkExp',{
					id:itemID,
				},"POST").then(()=>{
					this.deleteFuns(index,type);
				})
			},
			// https://app.zizijy.com/api/user/curriculum_vitae/delworkExp
			userInfo(){
				   Request('/user/info').then((res)=>{
					   this.userInfoJson=res;
					   console.log(res);
					   this.formData={
						   ...res,
						   current_residence:res.current_residence?res.current_residence.split(','):[],
						   census_register:res.census_register?res.census_register.split(','):[],
						   label:res.label?res.label.split(','):[]
					   }
				   })
			},
		}
	}
</script>

<style scoped>
	.imgListConter{
		display: flex;
		align-items: center;
		flex-wrap: wrap;
	}
	.imgListConter .imgList{
		margin-right: 10rpx;
		width: 110rpx;
		height: 110rpx;
		margin-bottom: 10rpx;
		border-radius: 10rpx;
	}
	.comteMenst{
		width: 750px;
		height: 480px;
		background: linear-gradient( 180deg, #C9D4FF 0%, #F7F8FA 100%);
		border-radius: 0px 0px 0px 0px;
		position: fixed;
		z-index: 1;
	}
	.menTnegsMe{
		/* position: fixed; */
		position: relative;
		top: 90rpx;
		left: 0;
		z-index: 2;
		width: 100%;
	}
	.consmeComemenT{
		width: 638rpx;
		margin: 0 auto;
		box-sizing: border-box;
		padding: 24rpx;
		background: #F2F4F7;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}
	.consmeCome{
		width: 702rpx;
		margin: 0 auto;
		box-sizing: border-box;
		/* background: #FFFFFF; */
		background: linear-gradient(to right, #FFFFFF, #F0F2FC); /* 渐变背景 */
		border-bottom: 4px solid #C9D4FF; /* 下边框 */
		padding: 10px 0; /* 内边距 */
		border-radius: 24px 24px 24px 24px;
		margin-bottom: 16rpx;
		padding: 32rpx;
		
	}
	.tilrwme{
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 32rpx;
		color: #0D0E0F;
		font-style: normal;
		text-transform: none;
		margin-bottom: 24rpx;
	}
    .img{
		float: right;
		width: 20rpx;
		height: 20rpx;
	}
	.tianiazengs {
		border: 3rpx dashed #ccc;
		width: 701rpx;
		margin: 0 auto;
		font-size: 32rpx;
		border-radius: 20rpx;
		height: 100rpx;
		line-height: 100rpx;
		color: #646669;
		text-align: center;
		/* background-color: #FFFFFF; */
		background: linear-gradient(to right, #FFFFFF, #F0F2FC);
		margin-bottom: 16rpx;
	}
	.tilrwmeEme{
		display: flex;
		align-items: center;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 32rpx;
		color: #0D0E0F;
		font-style: normal;
		text-transform: none;
		margin-bottom: 24rpx;
	}
	.tilrwmeEme .xiusb{
		margin-right: 10rpx;
	}
	.tbs{
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		padding-top: 20rpx;
	}
	.imAvatar{
		width: 108rpx;
		height: 108rpx;
		border-radius: 50%;
	}
	.tbs .tbs-list{
		height: 64rpx;
		background: #F2F4F7;
		line-height: 64rpx;
		margin-right: 12rpx;
		padding: 0 10rpx;
		margin-bottom: 12rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #646669;
	}
	.comRime .com{
		font-size: 28rpx;
		font-weight: 400;
		margin-left: 10rpx;
		color: #3B5EEC;
	}
	.uneSunbtirle {
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		color: #0D0E0F;
		text-align: left;
		font-style: normal;
		text-transform: none;
	}
    .imgebs{
		width: 24rpx;
		height: 24rpx;
	}
	.tbsmens{
		height: 64rpx;
		text-align: center;
		display: flex;
		align-items: center;
		margin-bottom: 10rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #3B5EEC;
		text-align: left;
		font-style: normal;
		text-transform: none;
		background: #F0F2FC;
		padding: 0 24rpx;
		margin-right: 24rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}
	.tbsmens .tenImg{
		width: 28rpx;
		height: 28rpx;
		margin-right: 10rpx;
	}
	.mensetiem{
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #646669;
		text-align: left;
		margin: 8rpx 0;
		font-style: normal;
		text-transform: none;
	}
	.btn{
		width: 702rpx;
		height: 80rpx;
		line-height: 80rpx;
		background: #3B5EEC;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		color: #FFFFFF;
		text-align: center;
		font-style: normal;
		text-transform: none;
		margin: 0 auto;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}
</style>